package com.atguigu.tingshu.account.api;

import com.atguigu.tingshu.account.service.UserAccountService;
import com.atguigu.tingshu.common.anno.AuthLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.UserAccountDetail;
import com.atguigu.tingshu.vo.account.AccountLockResultVo;
import com.atguigu.tingshu.vo.account.AccountLockVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@Tag(name = "用户账户管理")
@RestController
@RequestMapping("api/account/userAccount")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserAccountApiController {

	@Autowired
	private UserAccountService userAccountService;
	// getAvailableAmount
	@AuthLogin
	@GetMapping("getAvailableAmount")
	public Result<BigDecimal> getAvailableAmount(){
		return Result.ok(userAccountService.getAvailableAmount());
	}

	@AuthLogin
	@PostMapping("checkAndLock")
	public Result<AccountLockResultVo> checkAndLock(@RequestBody AccountLockVo accountLockVo){
		return Result.ok(userAccountService.checkAndLock(accountLockVo));
	}

	// 	/api/account/userAccount/findUserConsumePage/1/10	消费记录
	@AuthLogin
	@GetMapping("/findUserConsumePage/{pageNo}/{pageSize}")
	public Result<IPage<UserAccountDetail>> findUserConsumePage(@PathVariable Integer pageNo,@PathVariable Integer pageSize){
		return Result.ok(userAccountService.findUserConsumePage(pageNo,pageSize));
	}
	// 	/api/account/userAccount/findUserRechargePage/1/10   充值记录
	@AuthLogin
	@GetMapping("/findUserRechargePage/{pageNo}/{pageSize}")
	public Result<IPage<UserAccountDetail>> findUserRechargePage(@PathVariable Integer pageNo,@PathVariable Integer pageSize){
		return Result.ok(userAccountService.findUserRechargePage(pageNo,pageSize));
	}

}

